<template>
  <div>
    <!--待办   待做-->
    <!--<el-card style="margin-bottom: 20px">
      <el-radio-group v-model="flag" @change="eventTypeChange" style="margin-bottom: 10px">
        <el-radio-button :label="1">待处理</el-radio-button>
        <el-radio-button :label="2">已处理</el-radio-button>
      </el-radio-group>
      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
        <el-form-item label="报修单位" prop="repairUnit">
          <el-input
              v-model="queryParams.repairUnit"
              placeholder="请输入报修单位"
              clearable
              style="width: 200px"
              @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="订单编号" prop="orderNo">
          <el-input
              v-model="queryParams.orderNo"
              placeholder="请输入订单编号"
              clearable
              style="width: 200px"
              @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="订单类型" prop="type">
          <el-select v-model="queryParams.type" placeholder="请选择订单类型" clearable style="width: 200px">
            <el-option
                v-for="dict in typeList"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-table v-loading="loading" :data="noticeList">
      <el-table-column label="序号" align="center" prop="index" width="60" type="index"/>
      <el-table-column label="订单编号" align="center" prop="orderNo" width="150" show-overflow-tooltip/>
      <el-table-column label="报修单位" align="center" prop="repairUnit" min-width="140" show-overflow-tooltip/>
      <el-table-column label="报修设备" align="center" prop="equipment" min-width="120" show-overflow-tooltip/>
      <el-table-column label="品牌" align="center" prop="brand" width="80"/>
      <el-table-column label="报修人" align="center" prop="customerName" width="80" show-overflow-tooltip/>
      <el-table-column label="订单状态" align="center" prop="type" width="80">
        <template #default="scope">
          <el-tag type="primary">{{
              scope.row.type === 1 ? '已报修' : scope.row.type === 2 ? '已接单' : scope.row.type === 3 ? '已预约' : scope.row.type === 4 ? '已到达' : scope.row.type === 6 ? '维修完成' : '已评价'
            }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="联系电话" align="center" prop="phone" width="120"/>
      <el-table-column label="问题描述" align="center" prop="description" min-width="100" show-overflow-tooltip/>
      <el-table-column fixed="right" label="操作" align="center" width="150" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button v-if="scope.row.type > 1" link type="primary" icon="Edit"
                     @click="handleToMake(scope.row,'订单处理')" size="small">操作
          </el-button>
          <el-button v-if="scope.row.type == 1" link type="primary" icon="Edit"
                     @click="handleToMake(scope.row,'订单分派')" size="small">操作
          </el-button>
          <el-button link @click="handleDetail(scope.row)" size="small">详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.page"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />-->

    <OrderList></OrderList>
  </div>
</template>

<script setup name="Index">
import {getListOrders} from "@/api/system/orders.js";
import OrderList from "@/views/system/orders/index1.vue"

const type = {}
const flag = 1
const dataList = []
const version = ref('3.8.9')

const {proxy} = getCurrentInstance()

const noticeList = ref([])
const OrderDetail = ref({})//订单详情
const OrderNo = ref('')//订单详情
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const total = ref(0)
const title = ref("")

const detail = ref(null)
const assignment = ref(null)
const offer = ref(null)

const data = reactive({
  typeList: [
    {
      label: '已报修',
      value: 1
    }, {
      label: '已接单',
      value: 2
    }, {
      label: '已预约',
      value: 3
    }, {
      label: '已到达',
      value: 4
    }, {
      label: '维修完成',
      value: 5
    }, {
      label: '已评价',
      value: 6
    },
  ],
  queryParams: {
    page: 1,
    pageSize: 10,
    repairUnit: undefined,
    orderNo: undefined,
    type: undefined
  },
})

const {queryParams, typeList} = toRefs(data)

function goTarget(url) {
  window.open(url, '__blank')
}

// 切换radio状态
const eventTypeChange = (val, params) => {
  let searParams = {
    pageSize: 10,
    pageNum: 1,
  };
  searParams = params;
  switch (val) {
      // 待处理
    case 1:
      getPendingPage(searParams);
      break;
      // 已处理
    case 2:
      getProcessedPage(searParams);
      break;
      // 我发起
    case 3:
      getMeInitiatePage(searParams);
      break;
  }
  // 待处理
  const getPendingPage = (params) => {
    /*this.loading = true
    getToDoListByPage(params).then(res=>{
      this.dataList = res.data.rows
      this.total = res.data.total
      this.loading = false
    })*/
  }
  // 已处理
  const getProcessedPage = (params) => {

  }
  // 我发起
  const getMeInitiatePage = (params) => {

  }
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.page = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef")
  handleQuery()
}

/** 查询公告列表 */
function getList() {
  loading.value = true
  getListOrders(queryParams.value).then(response => {
    noticeList.value = response.data.list
    total.value = response.data.total
    loading.value = false
  })
}

// getList()
</script>

<style scoped lang="scss">

</style>

